<template>
    <div
        class="addStudent"
        v-loading="loading"
        element-loading-text="拼命添加中。。。。"
        element-loading-spinner="el-icon-loading"
    >
        <div class="addstu-box">
            <div class="title">
                <h1>基本信息</h1>
            </div>
            <div class="addstu-box-contain">
                <el-form
                    ref="studentInfoDetail2"
                    :rules="fieldRules"
                    :inline="true"
                    :model="info.studentInfoDetail.studentInfo"
                    class="demo-form-inline"
                >
                    <el-row>
                        <el-col :span="8">
                            <el-row>
                                <el-col :span="7">
                                    <i>学生姓名：</i>
                                </el-col>
                                <el-col :span="15">
                                    <el-input
                                        v-model="info.studentInfoDetail.studentInfo.name"
                                        placeholder="学生姓名"
                                    ></el-input>
                                </el-col>
                            </el-row>
                        </el-col>
                        <el-col :span="8">
                            <el-row>
                                <el-col :span="7">
                                    <i>学校名称：</i>
                                </el-col>
                                <el-col :span="15">
                                    <el-input
                                        v-model="info.studentInfoDetail.studentInfo.school"
                                        placeholder="学校名称"
                                    ></el-input>
                                </el-col>
                            </el-row>
                        </el-col>
                        <el-col :span="8">
                            <el-row>
                                <el-col :span="7">
                                    <i>学籍号：</i>
                                </el-col>
                                <el-col :span="15">
                                    <el-input
                                        v-model="info.studentInfoDetail.studentInfo.oemAccount"
                                        placeholder="学籍号"
                                    ></el-input>
                                </el-col>
                            </el-row>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-row>
                                <el-col :span="7">
                                    <i>学生学制：</i>
                                </el-col>
                                <el-col :span="15">
                                    <el-select
                                        v-model="info.studentInfoDetail.studentInfo.schoolSystem"
                                        placeholder="请选择"
                                        :change="student_system_cache_change"
                                    >
                                        <el-option
                                            v-for="item in student_system_cache_options"
                                            :key="item.fId"
                                            :label="item.fSystemName"
                                            :value="item.fId"
                                        ></el-option>
                                    </el-select>
                                </el-col>
                            </el-row>
                        </el-col>
                        <el-col :span="8">
                            <el-row>
                                <el-col :span="7">
                                    <i>就读年级：</i>
                                </el-col>
                                <el-col :span="15">
                                    <el-select
                                        v-model="info.studentInfoDetail.studentInfo.grade"
                                        placeholder="请选择"
                                        :change="student_grade_cache_change"
                                        filterable
                                    >
                                        <el-option
                                            v-for="item in grade_cache_gradeOptions"
                                            :key="item.value"
                                            :label="item.fGradeName"
                                            :value="item.fId"
                                        ></el-option>
                                    </el-select>
                                </el-col>
                            </el-row>
                        </el-col>
                        <el-col :span="8">
                            <el-row>
                                <el-col :span="7">
                                    <i>科目：</i>
                                </el-col>
                                <el-col :span="15">
                                    <el-select
                                        v-model="info.studentInfoDetail.studentInfo.subject"
                                        placeholder="请选择"
                                        filterable
                                    >
                                        <el-option
                                            v-for="item in subject_Options"
                                            :key="item.fId"
                                            :label="item.fSpecialtyName"
                                            :value="item.fId"
                                        ></el-option>
                                    </el-select>
                                </el-col>
                            </el-row>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-row>
                                <el-col :span="7">
                                    <i>家长姓名：</i>
                                </el-col>
                                <el-col :span="15">
                                    <el-input
                                        v-model="info.studentInfoDetail.studentInfo.parentName"
                                        placeholder="家长姓名"
                                    ></el-input>
                                </el-col>
                            </el-row>
                        </el-col>
                        <el-col :span="8">
                            <el-col :span="7">
                                <i>
                                    <em style="color:red">*</em> 联系电话：
                                </i>
                            </el-col>
                            <el-col :span="15">
                                <el-form-item label prop="phone" style="width:100%;">
                                    <el-input
                                        type="number"
                                        v-model="info.studentInfoDetail.studentInfo.phone"
                                        placeholder="联系电话"
                                    ></el-input>
                                </el-form-item>
                            </el-col>
                        </el-col>
                        <el-col :span="8">
                            <el-col :span="7">
                                <i>备用电话：</i>
                            </el-col>
                            <el-col :span="15">
                                <el-form-item label prop="phone" style="width:100%;">
                                    <el-input
                                        type="number"
                                        v-model="info.studentInfoDetail.studentInfo.sparePhone"
                                        placeholder="备用电话"
                                    ></el-input>
                                </el-form-item>
                            </el-col>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-row>
                                <el-col :span="7">
                                    <i>分主题：</i>
                                </el-col>
                                <el-col :span="15">
                                    <el-input
                                        v-model="info.studentInfoDetail.studentInfo.keyWords"
                                        placeholder="分主题"
                                    ></el-input>
                                </el-col>
                            </el-row>
                        </el-col>
                        <el-col :span="8">
                            <el-col :span="7">
                                <i>学生账号：</i>
                            </el-col>
                            <el-col :span="15">
                                <el-input
                                    v-model="info.studentInfoDetail.studentInfo.account"
                                    placeholder="学生账号"
                                ></el-input>
                            </el-col>
                        </el-col>
                        <el-col :span="8">
                            <el-col :span="7">
                                <i>导入部门：</i>
                            </el-col>
                            <el-col :span="15">
                                <el-form-item style="width:100% !important">
                                    <el-select
                                        clearable
                                        v-model="info.studentInfoDetail.studentInfo.importDepartment"
                                        placeholder="请选择"
                                    >
                                        <el-option
                                            v-for="item in student_import_department"
                                            :key="item.key"
                                            :label="item.value"
                                            :value="item.key"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-row>
                                <el-col :span="7">
                                    <i>页面地址：</i>
                                </el-col>
                                <el-col :span="15">
                                    <el-input
                                        v-model="info.studentInfoDetail.studentInfo.pageAddress"
                                        placeholder="页面地址"
                                    ></el-input>
                                </el-col>
                            </el-row>
                        </el-col>
                        <el-col :span="8">
                            <el-col :span="7">
                                <i>
                                    <em style="color:red">*</em> 客户来源：
                                </i>
                            </el-col>
                            <el-col :span="15">
                                <el-form-item label prop="dataFrom2" style="width:100%;">
                                    
                                        <el-cascader
                                        clearable
                                        filterable
                                        :key="is_cascader"
                                        v-model="info.studentInfoDetail.studentInfo.dataFrom2"
                                        :props="addressProps"
                                        :options="resources_Options2"
                                        placeholder="客户来源"
                                    ></el-cascader>
                                    
                                </el-form-item>
                            </el-col>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="2">
                            <i>所在地区：</i>
                        </el-col>
                        <el-col :span="10" style="text-algin:left; margin-left: 16px !important">
                            <el-cascader
                                size="large"
                                :options="options"
                                v-model="selectedOptions"
                                @change="handleChange"
                            ></el-cascader>
                        </el-col>
                        <el-col :span="8">
                            <el-input
                                v-model="info.studentInfoDetail.studentInfo.areaInput"
                                placeholder="请输入详细地址"
                            ></el-input>
                        </el-col>
                    </el-row>
                </el-form>
            </div>
        </div>
        <div class="addstu-box">
            <div class="title">
                <h1>客户信息</h1>
            </div>
            <div class="addstu-box-contain">
                <el-form
                    :inline="true"
                    ref="studentInfoDetail"
                    :rules="fieldRules"
                    :model="info.studentInfoDetail.studentInfo"
                    class="demo-form-inline"
                >
                    <el-row>
                        <el-col :span="8">
                            <el-row>
                                <el-col :span="7">
                                    <i>客户类型：</i>
                                </el-col>
                                <el-col :span="14">
                                    <el-select
                                        v-model="info.studentInfoDetail.studentInfo.type"
                                        placeholder="请选择"
                                    >
                                        <el-option
                                            v-for="item in student_type_options"
                                            :key="item.value"
                                            :label="item.value"
                                            :value="item.key"
                                        ></el-option>
                                    </el-select>
                                </el-col>
                            </el-row>
                        </el-col>
                        <el-col :span="8">
                            <el-row>
                                <el-col :span="6">
                                    <i>客户进展：</i>
                                </el-col>
                                <el-col :span="15">
                                    <el-select
                                        v-model="info.studentInfoDetail.studentInfo.progress"
                                        placeholder="请选择"
                                    >
                                        <el-option
                                            v-for="item in student_progress_options"
                                            :key="item.value"
                                            :label="item.value"
                                            :value="item.key"
                                        >{{item.value}}</el-option>
                                    </el-select>
                                </el-col>
                            </el-row>
                        </el-col>
                        <el-col :span="8">
                            <el-row>
                                <el-col :span="6">
                                    <i>获取方式</i>
                                </el-col>
                                <el-col :span="15">
                                    <el-select
                                        v-model="info.studentInfoDetail.studentInfo.dataFromType"
                                        filterable
                                        placeholder="请选择"
                                    >
                                        <el-option
                                            v-for="item in student_data_from_type_options"
                                            :key="item.value"
                                            :label="item.value"
                                            :value="item.key"
                                        >{{item.value}}</el-option>
                                    </el-select>
                                </el-col>
                            </el-row>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-row>
                                <el-col :span="6">
                                    <i>学生性别：</i>
                                </el-col>
                                <el-col :span="15">
                                    <el-radio-group
                                        v-model="info.studentInfoDetail.studentInfo.sex"
                                        style="margin-top:6%"
                                    >
                                        <el-radio label="1">男</el-radio>
                                        <el-radio label="2">女</el-radio>
                                    </el-radio-group>
                                </el-col>
                            </el-row>
                        </el-col>
                        <el-col :span="8">
                            <el-row>
                                <el-col :span="7">
                                    <i>学生年龄：</i>
                                </el-col>
                                <el-col :span="14">
                                    <el-input
                                        type="number"
                                        max="100"
                                        min="1"
                                        v-model="info.studentInfoDetail.studentInfo.age"
                                        placeholder
                                    ></el-input>
                                </el-col>
                            </el-row>
                        </el-col>
                        <el-col :span="8">
                            <el-row>
                                <el-col :span="8">
                                    <i>身份证号码：</i>
                                </el-col>
                                <el-col :span="14">
                                    <el-input
                                        v-model="info.studentInfoDetail.studentInfo.idCard"
                                        placeholder
                                    ></el-input>
                                </el-col>
                            </el-row>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-row>
                                <el-col :span="7">
                                    <i>微信：</i>
                                </el-col>
                                <el-col :span="14">
                                    <el-input
                                        v-model="info.studentInfoDetail.studentInfo.wechat"
                                        placeholder
                                    ></el-input>
                                </el-col>
                            </el-row>
                        </el-col>
                        <el-col :span="8">
                            <el-row>
                                <el-col :span="6">
                                    <i>QQ：</i>
                                </el-col>
                                <el-col :span="15">
                                    <el-input
                                        type="number"
                                        v-model="info.studentInfoDetail.studentInfo.qq"
                                        placeholder
                                    ></el-input>
                                </el-col>
                            </el-row>
                        </el-col>
                        <el-col :span="8">
                            <el-row>
                                <el-col :span="8">
                                    <i>邮箱：</i>
                                </el-col>
                                <el-col :span="14">
                                    <el-input
                                        type="email"
                                        v-model="info.studentInfoDetail.studentInfo.email"
                                        placeholder
                                    ></el-input>
                                </el-col>
                            </el-row>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-row>
                                <el-col :span="7">
                                    <i>与家长关系：</i>
                                </el-col>
                                <el-col :span="14">
                                    <el-input
                                        v-model="info.studentInfoDetail.studentInfo.relationShip"
                                    ></el-input>
                                </el-col>
                            </el-row>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="薄弱学科：" prop>
                                <el-checkbox-group
                                    v-model="student_weak_subject_select"
                                    @change="student_weak_subject_change"
                                >
                                    <el-checkbox
                                        v-for="item in student_weak_subject"
                                        :label="item.key"
                                        :key="item.value"
                                    >{{item.value}}</el-checkbox>
                                </el-checkbox-group>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row style="margin:0">
                        <el-col :span="24">
                            <span>
                                <i style="font-size:15px;font-weight: 500;">偏好教学风格：</i>
                            </span>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="专业能力：" prop>
                                <el-checkbox-group
                                    v-model="student_like_profession_ability_select"
                                    @change="student_like_profession_ability_change"
                                >
                                    <el-checkbox
                                        v-for="item in student_like_profession_ability"
                                        :label="item.key"
                                        :key="item.value"
                                        name="type"
                                    >{{item.value}}</el-checkbox>
                                </el-checkbox-group>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="授课方式：" prop>
                                <el-checkbox-group
                                    v-model="student_like_lecture_style_select"
                                    @change="student_like_lecture_style_change"
                                >
                                    <el-checkbox
                                        v-for="item in student_like_lecture_style"
                                        :label="item.key"
                                        :key="item.value"
                                        name="type"
                                    >{{item.value}}</el-checkbox>
                                </el-checkbox-group>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="语言表达：" prop>
                                <el-checkbox-group
                                    v-model="student_like_expression_select"
                                    @change="student_like_expression_change"
                                >
                                    <el-checkbox
                                        v-for="item in student_like_expression"
                                        :label="item.key"
                                        :key="item.value"
                                        name="type"
                                    >{{item.value}}</el-checkbox>
                                </el-checkbox-group>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="讲义板书：" prop>
                                <el-checkbox-group
                                    v-model="student_like_blackboard_select"
                                    @change="student_like_blackboard_writing_change"
                                >
                                    <el-checkbox
                                        v-for="item in student_like_blackboard_writing"
                                        :label="item.key"
                                        :key="item.value"
                                        name="type"
                                    >{{item.value}}</el-checkbox>
                                </el-checkbox-group>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="家长类型：" prop>
                                <el-checkbox-group
                                    v-model="student_parent_type_select"
                                    @change="student_parent_type_change"
                                >
                                    <el-checkbox
                                        v-for="item in student_parent_type"
                                        :label="item.key"
                                        :key="item.value"
                                        name="type"
                                    >{{item.value}}</el-checkbox>
                                </el-checkbox-group>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="24">
                            <el-col :span="3">
                                <i>备注：</i>
                            </el-col>
                            <el-col :span="21">
                                <el-input
                                    style="margin-left:-5%"
                                    v-model="info.studentInfoDetail.studentInfoAttr.comment"
                                    type="textarea"
                                ></el-input>
                            </el-col>
                        </el-col>
                    </el-row>
                </el-form>
            </div>
        </div>
        <KtButton
            :label="$t('action.close')"
            perms="true"
            size="medium"
            style="margin-right: 2%;"
            @click="closeSelectedTag"
        ></KtButton>
        <kt-button
            class="stu-btn"
            :label="$t('action.save')"
            perms="true"
            :loading="editLoading"
            size="medium"
            @click="handleSave('studentInfoDetail')"
        />
    </div>
</template>
<script>
import { hasPermission } from "@/permission/index.js";
import axios from "axios";
import KtButton from "@/views/Core/KtButton";
import api from "@/http/api";
import CrmTable from "@/views/Core/CrmTable";
import { regionData } from "element-china-area-data";
import { baseUrl } from "@/utils/global";
import { isMobile } from "@/utils/validate";
export default {
    name: "AddStudent",
    components: {
        KtButton,
        CrmTable
    },
    data() {
        return {
            studentInfoDetail: {
                tyoe: []
            },
            loading: false,
            saveBtnStatus: false,
            student_data_from_type_options: [
                {
                    label: " ",
                    key: " "
                }
            ],
            student_import_department: [],
            info: {
                studentInfoDetail: {
                    studentInfo: {
                        dataFrom2:[],
                        account: "",
                        age: "",
                        area: "",
                        areaInput: "",
                        assignDate: "",
                        assignType: "",
                        belongTo: "",
                        belongToType: "",
                        callDate: "",
                        callNum: "",
                        city: "",
                        code: "",
                        createDate: "",
                        createPeople: "",
                        createType: "",
                        dataFrom: "",
                        dataFromInterface: "",
                        dataFromType: "",
                        email: "",
                        grade: "",
                        id: "",
                        idCard: "",
                        importDepartment: "",
                        isLock: "",
                        isSign: "",
                        moveDate: "",
                        name: "",
                        nextTrackingDate: "",
                        oemAccount: "",
                        oemType: "",
                        oneLevelDepartment: "",
                        parentName: "",
                        phone: "",
                        progress: "",
                        provider: "",
                        providerAgent: "",
                        providerTeacher: "",
                        province: "",
                        qq: "",
                        relationShip: "",
                        school: "",
                        schoolSystem: "",
                        sex: "",
                        signDate: "",
                        signNum: "",
                        threeLevelDepartment: "",
                        trackingDate: "",
                        trackingNum: "",
                        trackingPeople: "",
                        twoLevelDepartment: "",
                        type: "",
                        updateDate: "",
                        wechat: "",
                        subject: ""
                    },
                    studentInfoAttr: {
                        comment: "",
                        id: "",
                        likeBlackboardWriting: "",
                        likeExpression: "",
                        likeLectureStyle: "",
                        likeProfessionAbility: "",
                        parentType: "",
                        signStrategy: "",
                        studentId: "",
                        weakSubject: ""
                    }
                }
            },
            //   表单验证
            fieldRules: {
                name: [
                    {
                        required: true,
                        message: "请输入学生姓名",
                        trigger: "blur"
                    }
                ],
                school: [
                    { required: true, message: "学校名称", trigger: "blur" }
                ],
                oemAccount: [
                    { required: true, message: "请输入学籍号", trigger: "blur" }
                ],
                schoolSystem: [
                    {
                        required: true,
                        message: "请输入学生学制",
                        trigger: "blur"
                    }
                ],
                grade: [
                    {
                        required: true,
                        message: "请输入就读年级",
                        trigger: "blur"
                    }
                ],
                account: [
                    {
                        required: true,
                        message: "请输入学生账号",
                        trigger: "blur"
                    }
                ],
                parentName: [
                    {
                        required: true,
                        message: "请输入家长姓名",
                        trigger: "blur"
                    }
                ],
                phone: [
                    {
                        required: true,
                        message: "请输入联系电话",
                        trigger: "blur"
                    }
                ],
                type: [
                    {
                        type: "array",
                        required: true,
                        message: "请至少选择一项",
                        trigger: "change"
                    }
                ],
                dataFrom2: [
                    {
                        required: true,
                        message: "请选择客户来源",
                        trigger: "change"
                    }
                ]
            },
            student_data_from_options: [
                {
                    label: " ",
                    key: " "
                }
            ],
            student_type_options: [
                {
                    label: " ",
                    key: " "
                }
            ],
            student_progress_options: [
                {
                    label: " ",
                    key: " "
                }
            ],
            student_system_cache_options: [
                {
                    label: " ",
                    key: " "
                }
            ],
            grade_cache_gradeOptions: [
                {
                    label: " ",
                    key: " "
                }
            ],
            //   地区
            options: regionData,
            selectedOptions: [],
            student_like_profession_ability: [],
            student_weak_subject: [],
            student_like_expression: [],
            student_like_blackboard_writing: [],
            student_sign_strategy: [],
            student_parent_type: [],
            student_like_lecture_style: [],
            student_order_product_options: [],
            //   多选选中后的数组
            student_parent_type_select: [],
            student_like_blackboard_select: [],
            student_like_expression_select: [],
            student_like_lecture_style_select: [],
            student_like_profession_ability_select: [],
            student_weak_subject_select: [],
            student_sign_strategy_select: [],
            subject_Options: [],
            selection: false,
            stuTableData: [],
            // 客户跟进数据
            followdata: [],
            columns: [
                { prop: "id", label: "序号", minWidth: 50 },
                { prop: "usernumber", label: "跟进时间", minWidth: 80 },
                { prop: "name", label: "联系人", minWidth: 80 },
                { prop: "OEM", label: "沟通形式", minWidth: 80 },
                { prop: "OEMcategory", label: "客户类型", minWidth: 100 },
                { prop: "role", label: "客户进展", minWidth: 70 },
                {
                    prop: "threeDepartment",
                    label: "下次跟进时间",
                    minWidth: 100
                }
            ],
            pageResult: {},
            pageRequest: { pageNum: 1, pageSize: 8 },
            editLoading: false,
            pageName: "",
            student_data_from_options_son:[

            ],
            resources_Options:[],
            resources_Options2: [],
            addressArr: [], //绑定的数据
            is_cascader: Math.random(), //重新渲染标识key
            addressProps: {
                label: "codeValue",
                value: "codeKey",
                lazy: true, //开启异步加载
                lazyLoad(node, resolve) {
                    
                    const { value, level } = node;
                    axios
                        .get(baseUrl + "/code/queryStudentDataFromByGroupId", {
                            params: { id: node.value }
                        })
                        .then(res => {
                            let response = res.data;

                            if (response.result == 1) {
                                resolve(
                                    response.data.map(item => {
                                        item.label = item.label;
                                        item.value = item.codeKey;
                                        item.leaf = "leaf"; //这个必须加，就是让组件识别是不是最后一级
                                        return item;
                                        
                                    })
                                );
                            }
                        });
                }
            },
            addressInit: false, //标记组件第一级数据开始加载没有
        };
    },
    watch: {
        // $route: "getParams"
    },
    beforeMount: function() {
        let name = this.$route.query.name;
        this.pageName = name;
        this.$api.dropdown.studentDataFromGroup().then(res => {
                if (res.result == 1) {
                    this.resources_Options = res.keyValueList;
                }
            });
        this.$api.dropdown.studentDataFromGroup().then(res => {
            if (res.result == 1) {
                this.resources_Options = res.keyValueList;
                let arr = res.keyValueList;
                this.resources_Options2 = arr.map(item => {
                    item.codeValue = item.value;
                    item.codeKey = item.key;
                    return item;
                });
            }
        });
    },
    methods: {
        hasPerms: function(perms) {
            // 根据权限标识和外部指示状态进行权限判断
            return hasPermission(perms) & !this.disabled;
        },
        handleClose() {
            this.$router.push({ path: "/Customer/Stu" });
        },

        handleFollow(index, row) {
            this.$emit("handleFollow", { index: index, row: row });
            this.dataForm = Object.assign({}, params.row);
            this.$router.push({ path: "/Follow/StudentFollow" });
        },
        handleSave(studentInfoDetail) {
            this.editLoading = true;
            let data = Object.assign({}, this.info);
            let province = this.selectedOptions[0];
            let city = this.selectedOptions[1];
            let area = this.selectedOptions[2];
            this.info.studentInfoDetail.studentInfo.province = province;
            this.info.studentInfoDetail.studentInfo.city = city;
            this.info.studentInfoDetail.studentInfo.area = area;
            let phone1 = this.info.studentInfoDetail.studentInfo.phone;
            let phone2 = this.info.studentInfoDetail.studentInfo.sparePhone;
            if(this.info.studentInfoDetail.studentInfo.dataFrom2.length>0){
                this.info.studentInfoDetail.studentInfo.dataFrom=this.info.studentInfoDetail.studentInfo.dataFrom2[1]
                // this.info.studentInfoDetail.studentInfo.dataFrom2 = this.info.studentInfoDetail.studentInfo.dataFrom2.toString();
            }
            
            if (phone1 != "") {
                if (!isMobile(phone1)) {
                    this.$message.error("请输入正确的手机号！");
                    return;
                }
                this.editLoading = false;
            }
            if ((phone2 != undefined) & (phone2 != "")) {
                if (!isMobile(phone2)) {
                    this.$message.error("请输入正确的备用手机号！");
                    return;
                }
                this.editLoading = false;
            }
            if (
                this.info.studentInfoDetail.studentInfo.sparePhone ==
                this.info.studentInfoDetail.studentInfo.phone
            ) {
                this.$message({
                    message: "备用电话与主电话一致！",
                    center: true,
                    type: "error"
                });
                return false;
                this.editLoading = false;
            }
            if (this.pageName == "resourceAssignAdd") {
                this.$refs.studentInfoDetail2.validate(valid => {
                    if (valid) {
                        this.loading = true;
                        this.$api.student.resourceAssignAdd(data).then(res => {
                            if (res.result === 1) {
                                this.$message({
                                    message: res.msg,
                                    center: true,
                                    type: "success"
                                });
                                this.loading = false;
                                this.editLoading = false;
                                this.$refs.studentInfoDetail.resetFields();
                                this.closeSelectedTag();
                            } else if (res.result === 2) {
                                this.$message({
                                    message: res.msg,
                                    center: true,
                                    type: "error"
                                });
                                this.editLoading = false;
                                this.loading = false;
                            }
                        });
                    } else {
                        this.$message({
                            message: "请填写关键字段",
                            center: true,
                            type: "error"
                        });
                        this.editLoading = false;
                        this.loading = false;
                        return false;
                    }
                });
            }
            if (this.pageName == "customerManager") {
                this.$refs.studentInfoDetail2.validate(valid => {
                    if (valid) {
                        this.loading = true;
                        this.$api.user.addCusomer(data).then(res => {
                            if (res.result === 1) {
                                this.$message({
                                    message: res.msg,
                                    center: true,
                                    type: "success"
                                });
                                this.editLoading = false;
                                this.loading = false;
                                this.closeSelectedTag();
                                this.$refs.studentInfoDetail.resetFields();
                            } else if (res.result === 2) {
                                this.$message({
                                    message: res.msg,
                                    center: true,
                                    type: "error"
                                });
                                this.editLoading = false;
                                this.loading = false;
                            }
                        });
                    } else {
                        this.$message({
                            message: "请填写关键字段",
                            center: true,
                            type: "error"
                        });
                        this.editLoading = false;
                        this.loading = false;
                        return false;
                    }
                });
            }
            if (this.pageName == "customerAssignAdd") {
                this.$refs.studentInfoDetail2.validate(valid => {
                    if (valid) {
                        this.loading = true;
                        this.$api.student.customerAssignAdd(data).then(res => {
                            if (res.result === 1) {
                                this.$message({
                                    message: res.msg,
                                    center: true,
                                    type: "success"
                                });
                                this.editLoading = false;
                                this.loading = false;
                                this.closeSelectedTag();
                                this.$refs.studentInfoDetail.resetFields();
                            } else if (res.result === 2) {
                                this.$message({
                                    message: res.msg,
                                    center: true,
                                    type: "error"
                                });
                                this.editLoading = false;
                                this.loading = false;
                            }
                        });
                    } else {
                        this.$message({
                            message: "请填写关键字段",
                            center: true,
                            type: "error"
                        });
                        this.editLoading = false;
                        this.loading = false;
                        return false;
                    }
                });
            }
            if (this.pageName == "myCustomerAdd") {
                this.$refs.studentInfoDetail2.validate(valid => {
                    if (valid) {
                        this.loading = true;
                        this.$api.student.myCustomerAdd(data).then(res => {
                            if (res.result === 1) {
                                this.$message({
                                    message: res.msg,
                                    center: true,
                                    type: "success"
                                });
                                this.editLoading = false;
                                this.loading = false;
                                this.closeSelectedTag();
                                this.$refs.studentInfoDetail.resetFields();
                            } else if (res.result === 2) {
                                this.$message({
                                    message: res.msg,
                                    center: true,
                                    type: "error"
                                });
                                this.editLoading = false;
                                this.loading = false;
                            }
                        });
                    } else {
                        this.$message({
                            message: "请填写关键字段",
                            center: true,
                            type: "error"
                        });
                        this.editLoading = false;
                        this.loading = false;
                        return false;
                    }
                });
            }
            if (this.pageName == "schoolResources") {
                this.$refs.studentInfoDetail2.validate(valid => {
                    if (valid) {
                        this.loading = true;
                        this.$api.student.schoolCustomerAdd(data).then(res => {
                            if (res.result === 1) {
                                this.$message({
                                    message: res.msg,
                                    center: true,
                                    type: "success"
                                });
                                this.loading = false;
                                this.editLoading = false;
                                this.closeSelectedTag();
                                this.$refs.studentInfoDetail.resetFields();
                            } else if (res.result === 2) {
                                this.$message({
                                    message: res.msg,
                                    center: true,
                                    type: "error"
                                });
                                this.editLoading = false;
                                this.loading = false;
                            }
                        });
                    } else {
                        this.$message({
                            message: "请填写关键字段",
                            center: true,
                            type: "error"
                        });
                        this.editLoading = false;
                        this.loading = false;
                        return false;
                    }
                });
            }
        },
        // 获取地区
        handleChange(value) {
            console.log(this.selectedOptions[0]);
        },

        get_profession_ability(params) {
            this.$api.user
                .optionsList({ codeType: "student_like_profession_ability" })
                .then(res => {
                    this.student_like_profession_ability = res.keyValueList;
                });
        },
        get_student_weak_subject() {
            this.$api.user
                .optionsList({ codeType: "student_weak_subject" })
                .then(res => {
                    this.student_weak_subject = res.keyValueList;
                });
        },
        get_student_like_lecture_style() {
            this.$api.user
                .optionsList({ codeType: "student_like_lecture_style" })
                .then(res => {
                    this.student_like_lecture_style = res.keyValueList;
                });
        },
        get_student_like_expression() {
            this.$api.user
                .optionsList({ codeType: "student_like_expression" })
                .then(res => {
                    this.student_like_expression = res.keyValueList;
                });
        },
        get_student_like_blackboard_writing() {
            this.$api.user
                .optionsList({ codeType: "student_like_blackboard_writing" })
                .then(res => {
                    this.student_like_blackboard_writing = res.keyValueList;
                });
        },
        get_student_parent_type() {
            this.$api.user
                .optionsList({ codeType: "student_parent_type" })
                .then(res => {
                    this.student_parent_type = res.keyValueList;
                });
        },
        get_student_sign_strategy() {
            this.$api.user
                .optionsList({ codeType: "student_sign_strategy" })
                .then(res => {
                    this.student_sign_strategy = res.keyValueList;
                });
        },
        get_student_data_from() {
            this.$api.user
                .optionsList({ codeType: "student_data_from" })
                .then(res => {
                    this.student_data_from_options = res.keyValueList;
                });
        },
        get_student_type() {
            this.$api.user
                .optionsList({ codeType: "student_type" })
                .then(res => {
                    this.student_type_options = res.keyValueList;
                });
        },
        get_student_progress() {
            this.$api.user
                .optionsList({ codeType: "student_progress" })
                .then(res => {
                    this.student_progress_options = res.keyValueList;
                });
        },
        get_system_cache() {
            this.$api.user
                .optionsList({ codeType: "system_cache" })
                .then(res => {
                    this.student_system_cache_options = res.systemList;
                });
        },
        get_grade_cache() {
            this.$api.user
                .optionsList({ codeType: "grade_cache" })
                .then(res => {
                    this.grade_cache_gradeOptions = res.commonGradeList;
                });
        },
        get_student_order_product() {
            this.$api.user
                .optionsList({ codeType: "student_order_product" })
                .then(res => {
                    this.student_order_product_options = res.keyValueList;
                });
        },
        // 获取方式
        get_student_data_from_type() {
            this.student_data_from_type_options = JSON.parse(
                localStorage.getItem("stdentDataFromType")
            );
            this.subject_Options = JSON.parse(
                localStorage.getItem("studentSubject")
            );
        },
        student_parent_type_change(value) {
            this.info.studentInfoDetail.studentInfoAttr.parentType = value.toString();
            console.log(value.length);
        },
        student_like_blackboard_writing_change(value) {
            this.info.studentInfoDetail.studentInfoAttr.likeBlackboardWriting = value.toString();
        },
        student_like_expression_change(value) {
            this.info.studentInfoDetail.studentInfoAttr.likeExpression = value.toString();
        },
        student_like_lecture_style_change(value) {
            this.info.studentInfoDetail.studentInfoAttr.likeLectureStyle = value.toString();
        },
        student_like_profession_ability_change(value) {
            this.info.studentInfoDetail.studentInfoAttr.likeProfessionAbility = value.toString();
        },
        student_weak_subject_change(value) {
            this.info.studentInfoDetail.studentInfoAttr.student_weak_subject_change = value.toString();
        },
        student_sign_strategy_change(value) {
            this.info.studentInfoDetail.studentInfoAttr.signStrategy = value.toString();
        },
        student_data_from_change(value) {
          this.info.studentInfoDetail.studentInfo.dataFrom=''
            if(value!=''){
              this.$api.dropdown
              .queryStudentDataFromByGroupId({
                  id:value
              })
              .then(res => {
                  if (res.result == 2) {
                      this.$message({ message: res.msg, type: 'error' });
                  } else {
                      this.student_data_from_options_son=res.data
                  }
              });
            }
            // this.info.studentInfoDetail.studentInfo.dataFrom = value.toString();
        },
        student_progress_change(value) {
            this.info.studentInfoDetail.studentInfoAttr.student_progressValue = value.toString();
        },
        student_system_cache_change(value) {
            this.info.studentInfoDetail.studentInfo.schoolSystem = value.toString();
        },
        student_grade_cache_change(value) {
            this.info.studentInfoDetail.studentInfoAttr.grade_cacheValue = value.toString();
        },
        student_order_product_change(value) {
            this.info.studentInfoDetail.studentInfoAttr.grade_cacheValue = value.toString();
        },
        // 获取导入部门
        get_student_importDepartment() {
            this.$api.user
                .optionsList({ codeType: "student_import_department" })
                .then(res => {
                    this.student_import_department = res.keyValueList;
                });
        },
        isActive(route) {
            return route.path === this.$route.path;
        },
        closeSelectedTag(view) {
            this.$store.dispatch("delVisitedViews", this.$route).then(views => {
                if (this.isActive(this.$route)) {
                    const latestView = views.slice(-1)[0];
                    if (latestView) {
                        this.$router.push(latestView);
                    } else {
                        this.$router.push("/");
                    }
                }
            });
        }
    },
    mounted() {
        this.get_profession_ability();
        this.get_student_weak_subject();
        this.get_student_like_lecture_style();
        this.get_student_like_expression();
        this.get_student_like_blackboard_writing();
        this.get_student_parent_type();
        this.get_student_sign_strategy();
        this.get_student_data_from();
        this.get_student_type();
        this.get_student_progress();
        this.get_system_cache();
        this.get_grade_cache();
        this.get_student_order_product();
        this.get_student_data_from_type();
        this.get_student_importDepartment();
    }
};
</script>
<style lang='scss' scoped>
.addstu-box-contain {
    .el-row {
        .el-col i {
            font-style: normal;
            text-align: right;
            float: left;
            font-size: 14px;
            color: #606266;
            line-height: 40px;
            padding: 0 0 0 0;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
        }
    }
}
.addstu-box {
    text-align: left;
    width: 90%;
    margin: 20px auto;
    border: 1px solid #e4e7ed;
    padding-bottom: 20px;
    .el-row {
        margin: 0 0 2% 0;
    }
    .el-row .el-col {
        margin-left: 0 !important;
    }
    .container .el-radio-group .el-radio:first-child {
        display: inline-block !important;
    }

    .el-select {
        width: 100%;
    }
    .title h1 {
        font-size: 20px;
        font-weight: bold;
        padding: 20px;
    }

    .city-title {
        text-align: right;
        float: left;
        font-size: 14px;
        color: #606266;
        line-height: 40px;
        padding: 0 0 0 0;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
    }
}
.el-checkbox {
    margin-right: 30px;
}
.el-checkbox + .el-checkbox {
    margin-left: 0px;
}
.addStudent .addstu-box-contain {
    margin: 0 auto;
}
</style>
<style lang="scss">
.addstu-box {
    .el-cascader {
        width: 100%;
    }
}
.addStudent input::-webkit-outer-spin-button,
.addStudent input::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0;
}
.addStudent .el-form--inline .el-form-item__content {
    width: 100%;
}
.addStudent .el-select {
    width: 100%;
}
.addStudent .el-form--inline .el-form-item {
    margin-bottom: 0 !important;
}
.addStudent .addstu-box .el-cascader {
    width: 100% !important;
}
</style>


